import router from "@/router";
import { useStore } from "@/stores/counter";
import { routerHis, activ } from "@/hooks/routerHi";
import { deleteRouters } from "@/hooks/index";
import route from "@/router";
import { ElMessageBox } from "element-plus";

export default function out(e: string) {
	ElMessageBox.confirm(`${e}`)
		.then(() => {
			//回到登录页面
			const store = useStore();
			store.$reset();
			localStorage.clear();
			// Cookies.remove('token')
			routerHis.value = [
				{
					value: "首页",
					path: "/home/indexdefault",
					parent: "",
					index: "0",
				},
			];
			activ.value = 0;

			router.push({
				path: "/sign",
			});

			// deleteRouters(route);
			// location.reload();
		})
		.catch(() => {
			// catch error
			const store = useStore();
			store.$reset();
			localStorage.clear();
			// Cookies.remove('token')
			routerHis.value = [
				{
					value: "首页",
					path: "/home/indexdefault",
					parent: "",
					index: "0",
				},
			];
			activ.value = 0;

			//回到登录页面
			router.push({
				path: "/sign",
			});
			deleteRouters(route);
			location.reload();
		});
}
